﻿<Application x:Class="Halfwit.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:Halfwit.Converters"
    ShutdownMode="OnExplicitShutdown"
    >
    <Application.Resources>
        <BooleanToVisibilityConverter x:Key="b2v" />
        <c:TweetWidthConverter x:Key="TweetWidth" />
        <c:FontScaleConverter x:Key="FontScale" />
        <c:FollowTextConverter x:Key="FollowText" />
        <c:MessageTextConverter x:Key="MessageText" />
        <c:IsMentionConverter x:Key="IsMention" />
        <c:IsMineConverter x:Key="IsMine" />
        <c:TwitterStatusUriConverter x:Key="TwitterStatusUri" />
        <c:TwitterTextConverter x:Key="TwitterText" />
        <c:TwitterDateTimeConverter x:Key="TwitterDateTime" />
        <c:StatusSourceConverter x:Key="StatusSource" />

        <LinearGradientBrush x:Key="TweetBackground" StartPoint="0,0" EndPoint="0,1" Opacity="0.2">
            <GradientStop Color="SkyBlue" Offset="0.2" />
            <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="MessageBackground" StartPoint="0,0" EndPoint="0,1" Opacity="0.2">
            <GradientStop Color="Orange" Offset="0.2" />
            <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="MentionBackground" StartPoint="0,0" EndPoint="0,1" Opacity="0.25">
            <GradientStop Color="Yellow" Offset="0.2" />
            <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="MyTweetBackground" StartPoint="0,0" EndPoint="0,1" Opacity="0.33">
            <GradientStop Color="LightGreen" Offset="0.2" />
            <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="SearchBackground" StartPoint="0,0" EndPoint="0,1" Opacity="0.25">
            <GradientStop Color="LightPink" Offset="0.2" />
            <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush 
            x:Key="ButtonBrush"
            Opacity="0.6"
            StartPoint="0,0" 
            EndPoint="0,1"
            >
            <GradientStop Color="AliceBlue" Offset="0" />
            <GradientStop Color="Azure" Offset="0.6" />
            <GradientStop Color="LightSkyBlue" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush 
            x:Key="ActiveButtonBrush"
            StartPoint="0,0" 
            EndPoint="0,1"
            >
            <GradientStop Color="AliceBlue" Offset="0" />
            <GradientStop Color="Azure" Offset="0.6" />
            <GradientStop Color="LightSkyBlue" Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush 
            x:Key="DisabledButtonBrush"
            StartPoint="0,0" 
            EndPoint="0,1"
            >
            <GradientStop Color="White" Offset="0"/>
            <GradientStop Color="WhiteSmoke" Offset="0.6" />
            <GradientStop Color="LightGray" Offset="1" />
        </LinearGradientBrush>

        <Style TargetType="Hyperlink" BasedOn="{StaticResource {x:Type Hyperlink}}">
            <Setter Property="Focusable" Value="False" />
        </Style>
        
        <Style TargetType="ButtonBase">
            <Setter Property="Width" Value="32" />
            <Setter Property="Height" Value="23" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="BorderBrush" Value="DarkGray" />
            <Setter Property="Background" Value="{StaticResource ButtonBrush}" />
            <Setter Property="BorderThickness" Value="1" />
            
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ButtonBase">
                        <Border
                            x:Name="PART_border"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="True"
                            Background="{TemplateBinding Background}"
                            Padding="{TemplateBinding Padding}"
                            >
                            <ContentPresenter
                                RecognizesAccessKey="True" 
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" Value="True">
                    <Setter Property="Background" Value="{StaticResource ActiveButtonBrush}" />
                </DataTrigger>

                <DataTrigger Binding="{Binding IsPressed,RelativeSource={RelativeSource Self}}" Value="True">
                    <Setter Property="BorderThickness" Value="2,2,1,1" />
                </DataTrigger>
                
                <DataTrigger Binding="{Binding IsEnabled,RelativeSource={RelativeSource Self}}" Value="False">
                    <Setter Property="Foreground" Value="Gray" />
                    <Setter Property="Background" Value="{StaticResource DisabledButtonBrush}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="FlatButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Type ButtonBase}}">
            <Setter Property="Margin" Value="0" />
            <Setter Property="Focusable" Value="False" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />

            <Style.Triggers>
                <DataTrigger Binding="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" Value="True">
                    <Setter Property="BorderBrush" Value="DarkGray" />
                </DataTrigger>

                <DataTrigger Binding="{Binding IsEnabled,RelativeSource={RelativeSource Self}}" Value="False">
                    <Setter Property="Background" Value="Transparent" />
                    <!--<Setter Property="BorderBrush" Value="DarkGray" />-->
                    <Setter Property="Opacity" Value="0.5" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="FlatToggleButtonStyle" TargetType="ToggleButton" BasedOn="{StaticResource {x:Type ButtonBase}}">
            <Setter Property="Margin" Value="0" />
            <Setter Property="Focusable" Value="False" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />

            <Style.Triggers>
                <DataTrigger Binding="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" Value="True">
                    <Setter Property="BorderBrush" Value="DarkGray" />
                </DataTrigger>

                <DataTrigger Binding="{Binding IsEnabled,RelativeSource={RelativeSource Self}}" Value="False">
                    <Setter Property="Background" Value="Transparent" />
                    <!--<Setter Property="BorderBrush" Value="DarkGray" />-->
                    <Setter Property="Opacity" Value="0.5" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Application.Resources>
</Application>
